"""
@Time: 2020/12/7 下午 7:28
@Author: jinzhuan
@File: re_data_enhance.py
@Desc: 
"""
import sys
sys.path.append('/data/jinzhuoran/cognlp')
sys.path.append('/data/zhuoran/cognlp')
sys.path.append('/data/zhuoran/code/cognlp')
import matplotlib.pyplot as plt
from cognlp import *
from cognlp.io.loader.rex import TrexReLoader
from cognlp.io.processor.rex import REXProcessor, data_sample
from cognlp.utils.util import load_json
loader = TrexReLoader()
data = loader.load_all('../data/re/trexfull/data/')
processor = REXProcessor(label_list=loader.get_labels(), path="../data/re/trexfull/data/")
processor.get_raw_data(data, path="../data/re/trexfull/data/data.json")

# print(1)
# dic = {}
# for r in data:
#     if r['label'] in dic:
#         dic[r['label']] += 1
#     else:
#         dic[r['label']] = 1
#
# dic = sorted(dic.items(), key=lambda d: d[1], reverse=True)
# keys = []
# values = []
# for d in dic[20:100]:
#     if d[0] not in '<unk>':
#         keys.append(d[0])
#         values.append(d[1])
# plt.bar(keys, values)
# plt.show()
